<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>v-bind</title>
    <style>
        .red{
            border: 1px solid red;
        }
    </style>
</head>
<body>
    <div id="app">
        <img :src="imgSrc" alt="">
        <img :src="imgSrc" alt="" :class="{red: isRed}" @click="toggleRed">
    </div>
    <!-- 开发环境版本，包含了有帮助的命令行警告 -->
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script>
        var app = new Vue({
            el: "#app",
            
            data: {
                imgSrc: "https://dss1.bdstatic.com/6OF1bjeh1BF3odCf/it/u=502366104,607823147&fm=85&app=79&f=JPEG?w=121&h=75&s=0377E936CD60EC13187902E002008035",
                isRed: false,
            },

            methods:{
                toggleRed: function(){
                    //用到data里的数据注意要用this
                    this.isRed = !this.isRed;
                },
            },
        })
    </script>
</body>
</html>